#pragma once
#include <string>
#include <functional>
#include <memory>
class Connection;
class TcpServer;
using func_t = std::function<void(std::weak_ptr<Connection>)>;
class Connection
{
public:
    Connection(int sock):_sock(sock)
    {}
    void SetHanlder(func_t recv, func_t send, func_t except)
    {
        _recv = recv;
        _send = send;
        _except = except;
    }
public:

    //链接套接字
    int _sock;

    //输入输出缓冲区
    std::string _inbuffer;
    std::string _outbuffer;

    //回调方法
    func_t _recv;
    func_t _send;
    func_t _except;

    //ip和port
    std::string _ip;
    uint16_t _port;

    std::weak_ptr<TcpServer> _tcpserver;
};